/*
 * Questa classe rappresenta l'intero traffico della rete
 */

using namespace std;

class TrafficNet
{
    private:
    vector< vector<TrafficLink> > matrice;

	public:
	TrafficNet();
	TrafficNet(int n);
	int getASOrigin(int i, int j);
	int getASDestination(int i, int j);
	bool addLink(int i, int j, string policy, int bandwidth, int latency, bool state);
    bool setTraffic(int i, int j, string key, int value, bool state);
    bool addTraffic(int i, int j, string key, int value);
	bool subTraffic(int i, int j, string key, int value);
    bool removeTraffic(int i, int j, string key, int value);
	int getTraffic(int i, int j, string key);
	int getTraffic(int i, int j);
	bool getState(int i, int j);
	bool setState(int i, int j, bool state);
	bool resize(int n);
	bool init();
	int getSize();
	bool reset();
	//list< pair<int,int> > killLinksWithAS(int number);
};

TrafficNet::TrafficNet()
{;}

TrafficNet::TrafficNet(int n)
{
    matrice.resize(n);
    for (int i=0; i<n; i++) matrice[i].resize(n);

    for (int i=0; i<n; i++)
        for (int j=0; j<n; j++)
            matrice[i][j] = TrafficLink(i, j, false);
}

int TrafficNet::getASOrigin(int i, int j)
{
    matrice[i][j].getASOrigin();
}

int TrafficNet::getASDestination(int i, int j)
{
    matrice[i][j].getASDestination();
}

bool TrafficNet::setTraffic(int i, int j, string key, int value, bool state)
{
    matrice[i][j].setTraffic(key, value, state);
}

bool TrafficNet::addTraffic(int i, int j, string key, int value)
{
    matrice[i][j].addTraffic(key, value);
    matrice[i][j].setState(true);

}

bool TrafficNet::subTraffic(int i, int j, string key, int value)
{
    matrice[i][j].subTraffic(key, value);
}


bool TrafficNet::removeTraffic(int i, int j, string key, int value)
{
    matrice[i][j].removeTraffic(key, value);
}

int TrafficNet::getTraffic(int i, int j, string key)
{
    return matrice[i][j].getTraffic(key);
}

int TrafficNet::getTraffic(int i, int j)
{
    return matrice[i][j].getTraffic();
}

bool TrafficNet::resize(int n)
{
    int dim = matrice.size();
    matrice.resize(n);
    for(int i = 0;i < n;++i)
        matrice[i].resize(n);

    for (int i=dim; i<n; i++)
        for (int j=dim; j<n; j++)
            matrice[i][j] = TrafficLink(i, j, false);
}

bool TrafficNet::init()
{
    int n = matrice.size();
    for (int i=0; i<n; i++)
        for (int j=0; j<n; j++)
            matrice[i][j] = TrafficLink(i, j, false);
}

bool TrafficNet::reset()
{
    int n = matrice.size();
    for (int i=0; i<n; i++)
        for (int j=0; j<n; j++)
            matrice[i][j] = TrafficLink(i, j, false);
}

int TrafficNet::getSize()
{
    return matrice.size();
}

bool TrafficNet::getState(int i, int j)
{
    matrice[i][j].getState();
}

bool TrafficNet::setState(int i, int j, bool state)
{
    matrice[i][j].setState(state);
}

//list< pair<int,int> > TrafficNet::killLinksWithAS(int number)
//{
//    list< pair<int, int> > lista;
//    //cout << "esco da getASPathPair()"<<endl;

//    int n = matrice.size();
//    for (int i=0; i<n; i++)
//        for (int j=0; j<n; j++)
//            if ((matrice[i][j].getASOrigin() == number) || (matrice[i][j].getASDestination() == number))
//            {
//                matrice[i][j].setState(false);
//                lista.push_back(make_pair (i,j));
//            }
//    return lista;
//}
